<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>=^.^=</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="info">
	<p><a href="https://github.com/yomotsu/camera-controls">GitHub repo</a></p>
	<button type="button" onclick="cameraControls.reset( true )">reset</button>
	<br>
	cameraControls.mouseButtons.left =
	<select onchange="cameraControls.mouseButtons.left = CameraControls.ACTION[ this.value ]">
		<option value="ROTATE" selected>CameraControls.ACTION.ROTATE</option>
		<option value="TRUCK">CameraControls.ACTION.TRUCK</option>
		<option value="OFFSET">CameraControls.ACTION.OFFSET</option>
		<option value="DOLLY">CameraControls.ACTION.DOLLY</option>
		<option value="ZOOM">CameraControls.ACTION.ZOOM</option>
		<option value="NONE">CameraControls.ACTION.NONE</option>
	</select>
	<br>
	cameraControls.mouseButtons.middle =
	<select onchange="cameraControls.mouseButtons.middle = CameraControls.ACTION[ this.value ]">
		<option value="ROTATE">CameraControls.ACTION.ROTATE</option>
		<option value="TRUCK">CameraControls.ACTION.TRUCK</option>
		<option value="OFFSET">CameraControls.ACTION.OFFSET</option>
		<option value="DOLLY" selected>CameraControls.ACTION.DOLLY</option>
		<option value="ZOOM">CameraControls.ACTION.ZOOM</option>
		<option value="NONE">CameraControls.ACTION.NONE</option>
	</select>
	<br>
	cameraControls.mouseButtons.right =
	<select onchange="cameraControls.mouseButtons.right = CameraControls.ACTION[ this.value ]">
		<option value="ROTATE">CameraControls.ACTION.ROTATE</option>
		<option value="TRUCK" selected>CameraControls.ACTION.TRUCK</option>
		<option value="OFFSET">CameraControls.ACTION.OFFSET</option>
		<option value="DOLLY">CameraControls.ACTION.DOLLY</option>
		<option value="ZOOM">CameraControls.ACTION.ZOOM</option>
		<option value="NONE">CameraControls.ACTION.NONE</option>
	</select>
	<br>
	cameraControls.mouseButtons.wheel =
	<select onchange="cameraControls.mouseButtons.wheel = CameraControls.ACTION[ this.value ]">
		<option value="ROTATE">CameraControls.ACTION.ROTATE</option>
		<option value="TRUCK">CameraControls.ACTION.TRUCK</option>
		<option value="OFFSET">CameraControls.ACTION.OFFSET</option>
		<option value="DOLLY" selected>CameraControls.ACTION.DOLLY</option>
		<option value="ZOOM">CameraControls.ACTION.ZOOM</option>
		<option value="NONE">CameraControls.ACTION.NONE</option>
	</select>
	<br>

	cameraControls.touches.one =
	<select onchange="cameraControls.touches.one = CameraControls.ACTION[ this.value ]">
		<option value="ROTATE" selected>CameraControls.ACTION.TOUCH_ROTATE</option>
		<option value="TRUCK">CameraControls.ACTION.TOUCH_TRUCK</option>
		<option value="OFFSET">CameraControls.ACTION.OFFSET</option>
		<option value="DOLLY">CameraControls.ACTION.DOLLY</option>
		<option value="ZOOM">CameraControls.ACTION.ZOOM</option>
		<option value="NONE">CameraControls.ACTION.NONE</option>
	</select>
	<br>
	cameraControls.touches.two =
	<select onchange="cameraControls.touches.two = CameraControls.ACTION[ this.value ]">
		<option value="TOUCH_DOLLY_TRUCK" selected>CameraControls.ACTION.TOUCH_DOLLY_TRUCK</option>
		<option value="TOUCH_DOLLY_OFFSET">CameraControls.ACTION.TOUCH_DOLLY_OFFSET</option>
		<option value="TOUCH_ZOOM_TRUCK">CameraControls.ACTION.TOUCH_ZOOM_TRUCK</option>
		<option value="TOUCH_ZOOM_OFFSET">CameraControls.ACTION.TOUCH_ZOOM_OFFSET</option>
		<option value="TOUCH_DOLLY">CameraControls.ACTION.TOUCH_DOLLY</option>
		<option value="TOUCH_ZOOM">CameraControls.ACTION.TOUCH_ZOOM</option>
		<option value="TOUCH_ROTATE">CameraControls.ACTION.TOUCH_ROTATE</option>
		<option value="TOUCH_TRUCK">CameraControls.ACTION.TOUCH_TRUCK</option>
		<option value="TOUCH_OFFSET">CameraControls.ACTION.TOUCH_OFFSET</option>
	</select>
	<br>
	cameraControls.touches.three =
	<select onchange="cameraControls.touches.three = CameraControls.ACTION[ this.value ]">
		<option value="TOUCH_DOLLY_TRUCK">CameraControls.ACTION.TOUCH_DOLLY_TRUCK</option>
		<option value="TOUCH_DOLLY_OFFSET">CameraControls.ACTION.TOUCH_DOLLY_OFFSET</option>
		<option value="TOUCH_ZOOM_TRUCK">CameraControls.ACTION.TOUCH_ZOOM_TRUCK</option>
		<option value="TOUCH_ZOOM_OFFSET">CameraControls.ACTION.TOUCH_ZOOM_OFFSET</option>
		<option value="TOUCH_DOLLY">CameraControls.ACTION.TOUCH_DOLLY</option>
		<option value="TOUCH_ZOOM">CameraControls.ACTION.TOUCH_ZOOM</option>
		<option value="TOUCH_ROTATE">CameraControls.ACTION.TOUCH_ROTATE</option>
		<option value="TOUCH_TRUCK" selected>CameraControls.ACTION.TOUCH_TRUCK</option>
		<option value="TOUCH_OFFSET">CameraControls.ACTION.TOUCH_OFFSET</option>
	</select>
</div>

<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );

const width  = window.innerWidth;
const height = window.innerHeight;
const clock = new THREE.Clock();
const scene  = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

const cameraControls = new CameraControls( camera, renderer.domElement );

const mesh = new THREE.Mesh(
	new THREE.BoxGeometry( 1, 1, 1 ),
	new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } )
);
scene.add( mesh );

const gridHelper = new THREE.GridHelper( 50, 50 );
gridHelper.position.y = - 1;
scene.add( gridHelper );

renderer.render( scene, camera );

( function anim () {

	const delta = clock.getDelta();
	const elapsed = clock.getElapsedTime();
	const updated = cameraControls.update( delta );

	// if ( elapsed > 30 ) { return; }

	requestAnimationFrame( anim );

	if ( updated ) {

		renderer.render( scene, camera );
		console.log( 'rendered' );

	}

} )();
</script>

</body>
</html>
